<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/19
 * Time: 16:29
 */

namespace app\qgroup\service;


use app\common\service\BaseService;
use app\qgroup\Event\Event;

class AnalysisMessageService extends BaseService
{
    /**
     *  分析信息
     * @param $msg string
     * @return array
     * @throws \think\exception\DbException
     */
    public function analysisMessage($msg)
    {
        $ps = PowerfulService::all();
        foreach ($ps as $name => $code){
            if (strpos($msg,$name)!==false){
                $nameArr = explode('_',$code);
                $name = '';
                foreach ($nameArr as $namestr){
                    $name .= strtoupper(substr($namestr,0,1)) . substr($namestr,1);
                }
                $r = Event::run($code,$msg,);
                if (!$r){
                    return ['msg'=>'',''=>''];
                }
            }
        }
        return ChatService::run($msg);
    }
}